import React from 'react'
import styles from './App.module.css'
import { FSon } from './FSon'
import { CSon } from './CSon'

export class Header extends React.Component {
  //初始化状态
  state = {
    message: '回来吃饭',
  }
  // 提供回调函数
  changeMessage = (newMsg: any) => {
    console.log('子组件传过来的数据:', newMsg)
    this.setState({
      message: newMsg,
    })
  }
  render() {
    const { message } = this.state
    return (
      <div className={styles.one}>
        <div>父</div>
        <FSon msg={message} changeMsg={this.changeMessage} />
        <CSon msg={message}></CSon>
      </div>
    )
  }
}
